package com.xcn.dsxm.main_public.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import static com.xcn.dsxm.main_public.constants.ConstantsDate.*;

public class Util_Data {

    /**
     * @param  TimeType 传入获取的数据类型 eg:YEAR
     */
    public static String getDataTime(String TimeType){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date=new Date();
        String dateString=sdf.format(date);
        if (TimeType==YEAR){
            return dateString.substring(0,4);
        }
        if (TimeType==MONTH){
            return dateString.substring(0,7);
        }
        if (TimeType==DAY){
            return dateString.substring(0,10);
        }
        if (TimeType==HOUR){
            return dateString.substring(0,13);
        }
        if (TimeType==MINUTE){
            return dateString.substring(0,16);
        }
        if (TimeType==SECOND){
            return dateString;
        }
        return null;
    }
}
